from docx import Document
import pandas as pd
res=[]
#docx库不支持doc格式
def read_table(docpath:str,n:int):
    '''docpath->word文件路径
    n->要读取文件中的第几个表格。从0开始
    返回表格数据的列表
    '''
    global res
    doc=Document(docpath)
    tb=doc.tables[n]

    for i in range(4,len(tb.rows)):
        data=[]
        row_cells=tb.rows[i].cells
        print(row_cells)
        for cell in row_cells:
            data.append(cell.text)
        res.append(data)
    return res
word_data=read_table(r'D:\桌面\农资打假1-6\鹤壁.docx',0)
# print(res)
# df=pd.DataFrame(res)
# print(df)
